﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartLib.Reflection
{
    internal static class TypeReflectionCache
    {
        private static TypeCache _cache = new TypeCache();

        private class TypeCache : Utils.ReaderWriterCache<Type, TypeReflection>
        {
            public TypeReflection GetTypeReflection(Type type, Func<TypeReflection> creator)
            {
                return FetchOrCreateItem(type, creator);
            }
        }

        public static TypeReflection FetchTypeReflection(Type type)
        {
            return _cache.GetTypeReflection(type, () => new TypeReflection(type));
        }
    }
}
